#include "sdatatype.h"
#include <iostream>

extern "C" {
#include <hdf/mfhdf.h>
}

namespace sds {

  SDataType SDataTypeConverter::convert(SInteger hdfType) {
    switch (hdfType) {
    case DFNT_CHAR:
      return CHAR;
    case DFNT_UCHAR:
      return UCHAR;
    case DFNT_INT8:
      return INT8;
    case DFNT_UINT8:
      return UINT8;
    case DFNT_INT16:
      return INT16;
    case DFNT_UINT16:
      return UINT16;
    case DFNT_INT32:
      return INT32;
    case DFNT_UINT32:
      return UINT32;
    case DFNT_INT64:
      return INT64;
    case DFNT_UINT64:
      return UINT64;
    case DFNT_FLOAT32:
      return FLOAT32;
    case DFNT_FLOAT64:
      return FLOAT64;
    }
    return UNDEFINED;
  }

  SInteger SDataTypeConverter::inverse(SDataType type) {
    switch (type) {
    case CHAR:
      return DFNT_CHAR;
    case UCHAR:
      return DFNT_UCHAR;
    case INT8:
      return DFNT_INT8;
    case UINT8:
      return DFNT_UINT8;
    case INT16:
      return DFNT_INT16;
    case UINT16:
      return DFNT_UINT16;
    case INT32:
      return DFNT_INT32;
    case UINT32:
      return DFNT_UINT32;
    case INT64:
      return DFNT_INT64;
    case UINT64:
      return DFNT_UINT64;
    case FLOAT32:
      return DFNT_FLOAT32;
    case FLOAT64:
      return DFNT_FLOAT64;
    default:
      return FAIL;
    }
  }
}
